<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="外协对账单" />
<%@ include file="../inc/PrintTitle.jsp"%>
<head>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doPrint(){
		ShowConfirm('确认框','确定开始打印吗？',340,80,"doPrintExt()");
	}
	function doPrintExt(){
		if(popRetVal!=null){
			var len=${fn:length(qr.list)};
			var isIE = (navigator.userAgent.indexOf('MSIE')>=0) || (navigator.userAgent.indexOf('Trident')>=0);
			document.getElementById("noPrinSpan").style.display="none";
			if(len>200 && isIE){
				iePrint("wb","${enterpriseInfo.doPrint}");
			}else{
				printContent("管理易-外协对账单","${enterpriseInfo.doPrint}","${enterpriseInfo.printWidth}");
			}
			document.getElementById("noPrinSpan").style.display="";
		}
	}
	function doCancel(){
		window.close();
	}
	function doDownload(){
		var str=getSearchCondiction();
		window.location='/cooper/CooperBillListForAccount.ihtm?content_type=EXCEL&'+str;
	}
	function getSearchCondiction(){
		var cooperatorId="${cooperator_id}";
		var startDate="${start_date}";
		var endDate="${end_date}";
		var type="${type}";
		var orderBy="${order_by}";
		return 'cooperator_id='+cooperatorId+'&start_date='+startDate+'&end_date='+endDate+'&type='+type+'&order_by='+orderBy;
	}
	function doPay(){
		var url="/finance/PayBillNew.ihtm?data_type=COO_ACCOUNT&"+getSearchCondiction();
		ShowIframe("付款",url,1024,500,"refreshWin()",900,600);
	}
	function refreshWin(){
		if(popRetVal!=null){
			var url='/cooper/CooperBillListForAccount.ihtm?'+getSearchCondiction();
			if(popRetVal.indexOf(";")!=-1){
				var arr=popRetVal.split(";");
				if(arr[1]!=null && arr[1]=="Y"){
					url=url+"&print_id="+arr[0]+"&print_bill=PAY";
					if(arr[2]!=null){
						url=url+"&print_detail="+arr[2];
					}
				}
			}
			window.location=url;
		}
	}
	function doRefresh(){
		var str=getSearchCondiction();
		window.location='/cooper/CooperBillListForAccount.ihtm?'+str;
	}
	function doPrintCallBack(){
		var printId="${printId}";
		var printBill="${printBill}";
		var printDetail="${printDetail}";
		if(printId!=null && printId!=""){
			if(printBill=="PAY"){
				showWin(900,600,"/finance/PayBillPrint.ihtm?id="+printId+"&print_detail="+printDetail);
			}else if(printBill=="ADJ"){
				showWin(900,600,"/finance/AdjustBillPrint.ihtm?id="+printId);
			}
		}
	}
	function showRelBill(id,code){
		showWin(900,600,"/cooper/CooperRelBillList.ihtm?id="+id+"&code="+code);
	}
</script>
</head>
<c:remove var="alertMsg" scope="session" /><!-- 不显示信息 -->
<body style="background-color:#FFFFFF" onLoad="doPrintCallBack();">
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td width="16%"><img src="${enterpriseInfo.loginImage}" /></td>
					<td width="68%" height="40px" align="center" class="FontLarge_Bold">${licenseInfo.enterpriseName} 外协对账单</td>
					<td width="16%">&nbsp;</td>
				</tr>
		  </table>			
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="ListTable">
				<tr class="ListTrPrint">
			      	<td class="FontSmall" width="35%">外协单位：${est.estName}</td>
			      	<td class="FontSmall" width="40%">起止日期：${start_date} 至 ${end_date}</td>
				    <td class="FontSmall" width="25%" >合同金额：${costTotal}</td>
				</tr>
				<tr class="ListTrPrint">
			      	<td class="FontSmall">已付金额：${payTotal}</td>
					<td class="FontSmall">调账金额：${adjustTotal}</td>
			      	<td class="FontSmall">尚欠金额：${remainTotal}</td>		      	
				</tr>	
				<tr class="ListTrPrint">
			      	<td class="FontSmall">地址：${est.address}</td>
					<td class="FontSmall">联系人：${est.linkman}</td>
			      	<td class="FontSmall">电话：${est.linkmanPhone}</td>		      	
				</tr>							  
		  </table>			
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="small_border">
				<tr class="ListTrPrint">
					<td width="12%" class="FontSmall_Bold">
				    <div align="center">单号</div></td>
					<td width="8%" class="FontSmall_Bold">
				    <div align="center">日期</div></td>
					<td width="10%" class="FontSmall_Bold">
				    <div align="center">项目类型</div></td>
					<td width="13%" class="FontSmall_Bold">
				    <div align="center">内容</div></td>
					<td width="9%" class="FontSmall_Bold">
				    <div align="center">材质</div></td>
					<td width="12%" class="FontSmall_Bold">
				    <div align="center">规格</div></td>
					<td width="6%" class="FontSmall_Bold">
					<div align="center">单位</div></td>
					<td width="6%" class="FontSmall_Bold">
				    <div align="center">数量</div></td>
					<td width="6%" class="FontSmall_Bold">
					<div align="center">单价</div></td>
					<td width="7%" class="FontSmall_Bold">
				    <div align="center">金额</div></td>
					<td width="11%" class="FontSmall_Bold">
				    <div align="center">制作要求</div></td>
				</tr>
				<c:forEach var="item" items="${qr.list}" varStatus="i">
				<c:set var="styleStr" value="style='color:blue'" />
				<c:if test="${item[4]!=0.00}"><c:set var="styleStr" value="style='font-weight:bold;color:blue'" /></c:if>
				<c:if test="${item[3]=='Y'}"><c:set var="styleStr" value="style='font-weight:bold;color:red'" /></c:if>
				<tr class="ListTrPrint" ${styleStr}>
					<td class="FontSmall" align="center"><a href="javascript:showRelBill('${item[0].billId}','${item[1]}');">${item[1]}</a></td>
					<td class="FontSmall" align="center"><fmt:formatDate value="${item[2]}" pattern="yyyy-MM-dd"/></td>
					<td class="FontSmall" align="center"><commonTag:showSimpleObjectName list="${mtList}" objectId="${item[0].makeTypeId}" /></td>
					<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item[0].finishedContent}" /></td>
					<td class="FontSmall" align="center">${item[0].proName}</td>
					<td class="FontSmall" align="center">
						<commonTag:parseEnterToBr source="${item[0].specification}" />
						<c:if test="${item[0].priceType=='AREA' || item[0].priceType=='LENGTH'}"> x <commonTag:parseBigDecimal source="${item[0].amount}" /></c:if>
					</td>
					<td class="FontSmall" align="center">
						<c:if test="${item[0].priceType=='AREA'}">平方米</c:if>
						<c:if test="${item[0].priceType=='LENGTH'}">
							<c:if test="${item[0].lengType=='M'}">米</c:if><c:if test="${item[0].lengType=='CM'}">公分</c:if>
						</c:if>
						<c:if test="${item[0].priceType=='AMOUNT'}">${item[0].unit}</c:if>
					</td>
					<td class="FontSmall">
					<div align="center">
						<c:if test="${item[0].priceType=='AREA' || item[0].priceType=='LENGTH'}"><commonTag:parseBigDecimal source="${item[0].squareNum}" /></c:if>
						<c:if test="${item[0].priceType=='AMOUNT'}"><commonTag:parseBigDecimal source="${item[0].amount}" /></c:if>
					</div>
					</td>
					<td class="FontSmall"><div align="center"><commonTag:parseBigDecimal source="${item[0].unitPrice}" /></div></td>
					<td class="FontSmall"><div align="center"><commonTag:parseBigDecimal source="${item[0].cost}" /></div></td>
					<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item[0].makeRequire}" /></td>
				</tr>
				</c:forEach>
				<tr  class="ListTrPrint" ><td colspan="11"  class="FontSmall" align="right">小计金额：${costTotal+favTotal}元&nbsp;扣除优惠金额：${favTotal}元&nbsp;合同金额(实收)：${costTotal}元</td></tr>
			</table>
			
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="ListTable">
				<tr class="ListTrPrint">
			      	<td class="FontSmall" align="right" width="86%">外协商确认：</td>
					<td class="FontSmall" width="14%">&nbsp;</td>
				</tr>
		  </table>
		</td>
	</tr>
	<c:if test="${codeRule.printFoot!=null && codeRule.printFoot!=''}">
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td class="FontSmall"><commonTag:parseEnterToBr source="${codeRule.printFoot}" /></td>
				</tr>
			</table>
		</td>
	</tr>
	</c:if>
	<tr id="noPrinSpan">
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td>
						<input type="button" id="printButton" class="Button" value="开始打印" onClick="doPrint();">
						<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';NO_EXPO_ACCO;')==-1}">
							<input type="button" id="printButton" class="Button" value=" 导 出 " onClick="doDownload();">
						</c:if>
						<input type="button" id="refreshButton" class="Button" value=" 刷新 " onClick="doRefresh();">
						<c:if test="${currentUser.user.userType==1 || fn:indexOf(currentUser.privs,';PAY_BILL;')!=-1}">
							<input type="button" id="receiveButton" class="Button" value=" 付款 " onClick="doPay();">
						</c:if>
						<input type="button" id="cancelButton" class="Button" value=" 退 出 " onClick="doCancel();">
					</td>
				</tr>
				<tr>
					<td class="FontSmall" style="color:grey">注：红色表示无欠款，加粗蓝色表示已部分付款，蓝色表示无付款</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</body>
</html>